<?php
//+---------------------------------------------------------------------------------------------------------------------
//| 人生是荒芜的旅行，冷暖自知，苦乐在心
//+---------------------------------------------------------------------------------------------------------------------
//| Author:Janmas <janmas@126.com>
//+---------------------------------------------------------------------------------------------------------------------
//| 表单生成器
//+---------------------------------------------------------------------------------------------------------------------


namespace helper\form;

/**
 * form表单生成器
 * @package helper\form
 */
class Builder
{
	protected $html = '';

	public function __construct($formData = []){
		$this->handle($formData);
	}

	public function handle($formdata){
		foreach ($formdata as $value){
			$method = $value['type'];
			if(method_exists(Form::class, $method)){
				$this->html .= Form::$method($value);
			}else{
				continue;
			}
		}
	}

	public function getHtml(){
		return $this->html;
	}

	public function __destruct()
	{
		unset($this->formData,$this->html);
	}
}